package OddsObjects;

public class NumericOdd {
	
	double decimalOdd;
	String description;

	public NumericOdd(String oddString, String oddDescription) {
		if(oddString.contains(".")) {
			createNumericOdd(Double.valueOf(oddString));
		} else if( oddString.contains("/")) {
			int divisionIndex = oddString.indexOf("/");
			int numerator = Integer.valueOf(oddString.substring(0, divisionIndex));
			int denominator = Integer.valueOf(oddString.substring(divisionIndex+1));
			createNumericOdd( numerator, denominator);
		} else {
			createNumericOdd(Integer.valueOf(oddString));
		}
		description = oddDescription;
	}

	private void createNumericOdd(Double decimalRepresentation) {
		decimalOdd = decimalRepresentation;
	}
	
	private void createNumericOdd(int numerator, int denominator){
		decimalOdd = 1 + (numerator+denominator);
	}
	
	private void createNumericOdd(int americanRepresentation) {
		if( americanRepresentation < 0) {
			decimalOdd = (100/americanRepresentation) + 1;
		} else {
			decimalOdd = (americanRepresentation+100)/100;
		}
	}

}
